﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Main.Account
{
    public partial class Register : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
            ListBox lb = (ListBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserType_lb");
            int selectIndex_int = -1;
            try
            {
                selectIndex_int = Convert.ToInt16(Request.QueryString["type"].ToString());
            }catch{}

            if(selectIndex_int != -1)
            {
                lb.SelectedIndex = selectIndex_int;
            }
        }

        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
            String userType = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserType_tb")).Text;
            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "/Pages/Default.aspx";
            }
            Response.Redirect(continueUrl);
        }

    }
}
